using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FoodMenuPanel : MonoBehaviour
{
    public GameObject foodMenuItem;
    public GameObject content;


    void OnEnable()
    {
        RendererList();
    }


    private void RendererList()
    {
        if (Data.foodMenuCfg == null) return;
        // 清空列表
        foreach (Transform child in content.transform)
        {
            Destroy(child.gameObject);
        }
        // 重新渲染列表
        for (int i = 0; i < Data.foodMenuCfg.Count; i++)
        {
            GameObject _item = Instantiate(foodMenuItem);
            _item.transform.SetParent(content.transform);
            _item.transform.localScale = Vector3.one;
            _item.GetComponent<FoodMenuItem>().initData(i);
        }

    }
}
